package gov.gfbzb.advice.controller;

import gov.gfbzb.advice.service.IChatService;
import gov.gfbzb.advice.util.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;

/**
 * 咨询控制器
 */
@RestController
@RequestMapping("/chat")
public class ChatController {

    // 注入聊天模型
    @Resource
    private IChatService chatService;

    /**
     * RAG 问答
     * @param message 问
     * @return 答
     */
    @GetMapping("/advice")
    public CompletableFuture<Result> advice(@RequestParam(value = "message", defaultValue = "什么时候体检") String message) {
        CompletableFuture<String> advice = chatService.advice(message);
        String answer = advice.join();
        return CompletableFuture.completedFuture(Result.success(answer));
    }
}
